package com.neuedu.his.dao;

import com.neuedu.his.utils.DBUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author 金山
 * 项目：jdbc-dao
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2024/11/1115:33
 */
public class BaseDao {



    public int update(String  sql ,Object... params){

        Connection conn = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        int count = 0;
        try {
            conn = DBUtils.getConnection();
            stmt = conn.prepareStatement(sql);

            //绑定变量
            DBUtils.bingStmtVar(stmt,params);
            //执行查询
            count = stmt.executeUpdate();

        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

        return  count;
    }
}
